﻿<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ViewRecipe.aspx.cs" Inherits="RecipeBookWeb.ViewRecipe" %>
<asp:Content ID="RecipeViewContent" ContentPlaceHolderID="MainContent" Runat="Server">
	<asp:Label runat="server" ID="ErrorLabel" Visible="false" Font-Bold="true" ForeColor="Red" />
    <asp:PlaceHolder runat="server" ID="BrowseRecipesPlaceHolder">
        <asp:ListView runat="server" ID="RecipeListView">
            <LayoutTemplate>
                <h2 class="title">Browse Recipes</h2>
                <blockquote>
                    <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
                </blockquote>
            </LayoutTemplate>
            <ItemSeparatorTemplate>
                <hr />
            </ItemSeparatorTemplate>
            <ItemTemplate>
                <h4><a href='<%# "ViewRecipe.aspx?RecipeID=" + DataBinder.Eval(Container.DataItem, "ID").ToString() %>'><%# DataBinder.Eval(Container.DataItem, "Name") %></a></h4>
                Average User Rating: <%# DataBinder.Eval(Container.DataItem, "CompositeRating") %> / 7<br />
                Serves <%# DataBinder.Eval(Container.DataItem, "ServingSize") %>.<br />
                Added by <%# DataBinder.Eval(Container.DataItem, "Username") %> on <%# ((DateTime)DataBinder.Eval(Container.DataItem, "DateAdded")).ToShortDateString() %>.<br />
                Categories:  <%# DataBinder.Eval(Container.DataItem, "CategoryList") %>
            </ItemTemplate>
        </asp:ListView>
    </asp:PlaceHolder>
    <asp:PlaceHolder runat="server" ID="IndividualRecipePlaceHolder">
        <h2><asp:Label runat="server" ID="RecipeNameLabel" /></h2>
        <asp:Table runat="server" ID="RecipeDetailTable" Width="98%" CellPadding="2" CellSpacing="2">
            <asp:TableRow>
                <asp:TableCell ColumnSpan="2" ID="FavoriteTableRow"><asp:Button runat="server" ID="FavoriteButton" Width="150" OnCommand="FavoriteButton_Clicked" CausesValidation="false" /></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableHeaderCell Width="20%" HorizontalAlign="Left">Average Rating:</asp:TableHeaderCell>
                <asp:TableCell><asp:Label runat="server" ID="AverageRatingLabel" /></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow ID="RateButtonsTableRow">
                <asp:TableCell ColumnSpan="2">
                    <asp:Button ID="Button1" runat="server" Text="1" OnCommand="RatingButton_Clicked" CommandArgument="1" Width="5" CausesValidation="false" />
                    <asp:Button ID="Button2" runat="server" Text="2" OnCommand="RatingButton_Clicked" CommandArgument="2" Width="5" CausesValidation="false" />
                    <asp:Button ID="Button3" runat="server" Text="3" OnCommand="RatingButton_Clicked" CommandArgument="3" Width="5" CausesValidation="false" />
                    <asp:Button ID="Button4" runat="server" Text="4" OnCommand="RatingButton_Clicked" CommandArgument="4" Width="5" CausesValidation="false" />
                    <asp:Button ID="Button5" runat="server" Text="5" OnCommand="RatingButton_Clicked" CommandArgument="5" Width="5" CausesValidation="false" />
                    <asp:Button ID="Button6" runat="server" Text="6" OnCommand="RatingButton_Clicked" CommandArgument="6" Width="5" CausesValidation="false" />
                    <asp:Button ID="Button7" runat="server" Text="7" OnCommand="RatingButton_Clicked" CommandArgument="7" Width="5" CausesValidation="false" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableHeaderCell HorizontalAlign="Left">Serving Size:</asp:TableHeaderCell>
                <asp:TableCell><asp:Label runat="server" ID="ServingSizeLabel" /></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableHeaderCell HorizontalAlign="Left">Added by User:</asp:TableHeaderCell>
                <asp:TableCell><asp:Label runat="server" ID="UserAddedLabel" /></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableHeaderCell HorizontalAlign="Left">Date Added:</asp:TableHeaderCell>
                <asp:TableCell><asp:Label runat="server" ID="DateAddedLabel" /></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableHeaderCell ID="CategoriesTableRow" HorizontalAlign="Left">Categories:</asp:TableHeaderCell>
                <asp:TableCell><asp:Label runat="server" ID="CategoriesLabel"></asp:Label></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableHeaderCell VerticalAlign="Top" HorizontalAlign="Left">Instructions:</asp:TableHeaderCell>
                <asp:TableCell><asp:Label runat="server" ID="InstructionsLabel" /></asp:TableCell>
            </asp:TableRow>
           <asp:TableRow ID="NutritionalInfoTableRow" HorizontalAlign="Left">
                <asp:TableHeaderCell VerticalAlign="Top" HorizontalAlign="Left">Nutritional Information:</asp:TableHeaderCell>
                <asp:TableCell><asp:Label runat="server" ID="NutritionalInfoLabel" /></asp:TableCell>
            </asp:TableRow>
        </asp:Table>
        
        <br />
        <asp:GridView runat="server" ID="IngredientGridView" AutoGenerateColumns="false" Width="98%" GridLines="None">
            <Columns>
                <asp:BoundField ItemStyle-Width="25%" DataField="Amount" HeaderText="Ingredients:" HeaderStyle-HorizontalAlign="Left" />
                <asp:BoundField DataField="Description" />
            </Columns>
        </asp:GridView>
        
        <br />
        <asp:GridView runat="server" ID="EquipmentGridView" AutoGenerateColumns="false" Width="98%" GridLines="None">
            <Columns>
                <asp:BoundField DataField="Description" HeaderText="Equipment:" HeaderStyle-HorizontalAlign="Left" />
            </Columns>
        </asp:GridView>
        
        <br />
        <asp:PlaceHolder runat="server" ID="AddCommentPlaceHolder">
            <b>Add a Comment:</b><br />
            <asp:RequiredFieldValidator runat="server" ControlToValidate="NewCommentTextBox" Display="Dynamic" ErrorMessage="You must enter text to post a comment." />
            <asp:TextBox runat="server" ID="NewCommentTextBox" TextMode="MultiLine" Columns="5" Width="70%" /><br />
            <asp:Button runat="server" ID="CommentButton" Text="Add Comment" Width="100" OnClick="CommentButton_Click" />
        </asp:PlaceHolder>
        <br />
        <asp:ListView runat="server" ID="CommentListView">
            <LayoutTemplate>
                <br />
                <h4>All Comments:</h4>
                <asp:PlaceHolder runat="server" ID="itemPlaceholder" />
            </LayoutTemplate>
            <ItemSeparatorTemplate>
                <br />
            </ItemSeparatorTemplate>
            <ItemTemplate>
                <%# DataBinder.Eval(Container.DataItem, "Username") %> says:<br />
                <%# DataBinder.Eval(Container.DataItem, "Text") %><br />
            </ItemTemplate>
            <EmptyDataTemplate>
                <br />
                No comments exist for this Recipe yet. You should add one!
            </EmptyDataTemplate>
        </asp:ListView>
    </asp:PlaceHolder>
</asp:Content>